<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <title>主页</title>
    <!-- 1. 导入CSS的全局样式 -->
    <link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet">
    <!-- 2. jQuery导入，建议使用1.9以上的版本 -->
    <script src="${pageContext.request.contextPath}/js/jquery-2.1.0.min.js"></script>
    <!-- 3. 导入bootstrap的js文件 -->
    <script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>

    <script>
        window.onload = function () {
            //获取第一个选项
            document.getElementById("firstCb").onclick = function () {
                var check = document.getElementsByName("userId");
                for (let i = 0; i < check.length; i++) {
                    check[i].checked = this.checked;
                }
            }
        }
    </script>
</head>
<body>
<div class="container">
    <div align="left">
        <a class="btn btn-primary" href="${pageContext.request.contextPath}/User/managerLogin">返回</a>
    </div>
    <br>
    <br>

    <!-- 出错显示的信息框 -->
    <c:if test="${requestScope.ban_msg!=null}">
        <div class="alert alert-warning alert-dismissible" role="alert">
            <button type="button" class="close" data-dismiss="alert">
                <span>&times;</span></button>
            <strong>${requestScope.ban_msg}</strong>
        </div>
    </c:if>

    <form action="${pageContext.request.contextPath}/User/banTime" method="post">
        <input type="number" name="banTime" class="form-control"  placeholder="请输入封禁时间(单位分钟)"/>
        <%--下面展示要操作的用户--%>
        <br>
        <table border="1" class="table table-bordered table-hover">
            <div class="form-group" style="text-align: left;">
                <input class="btn btn btn-primary" type="submit" value="封禁">
            </div>
            <tr class="success">
                <th><input type="checkbox" id="firstCb"></th>
                <th>编号</th>
                <th>用户名</th>
                <th>账号</th>
                <th>状态</th>
            </tr>
            <c:forEach items="${requestScope.userPageBean.list}" var="user" varStatus="s">
                <tr>
                    <td><input type="checkbox" name="userId" value="${user.id}"></td>
                    <td>${s.count}</td>
                    <td>${user.username}</td>
                    <td>${user.account}</td>
                    <td>${user.status}</td>
                </tr>
            </c:forEach>
        </table>
    </form>
    <%--下面这里是分页的数据--%>
    <div>
        <nav aria-label="Page navigation">
            <ul class="pagination">
                <%--这个li就是代表上一页的了--%>
                <c:if test="${requestScope.userPageBean.currentPage==1}">
                <li class="disabled">
                        <%--这里是一个禁用,但页码为1的时候不让用--%>
                    </c:if>
                    <c:if test="${requestScope.userPageBean.currentPage!=1}">
                <li>
                    </c:if>
                    <a href="${pageContext.request.contextPath}/User/banTimeList?currentPage=${requestScope.userPageBean.currentPage-1}&rows=5"
                       aria-label="Previous">
                        <span aria-hidden="true">&laquo;</span>
                    </a>
                </li>


                <c:forEach begin="1" end="${requestScope.userPageBean.totalPage}" var="i">
                    <%--上面这个显示的是激活状态
                    下面显示的是未激活状态 --%>
                    <c:if test="${requestScope.userPageBean.currentPage==i}">
                        <li class="active"><a
                                href="${pageContext.request.contextPath}/User/banTimeList?currentPage=${i}&rows=5">${i}</a>
                        </li>
                    </c:if>
                    <c:if test="${requestScope.userPageBean.currentPage!=i}">
                        <li>
                            <a href="${pageContext.request.contextPath}/User/banTimeList?currentPage=${i}&rows=5">${i}</a>
                        </li>
                    </c:if>
                </c:forEach>

                <c:if test="${requestScope.userPageBean.currentPage==requestScope.userPageBean.totalPage}">
                <li class="disabled">
                    </c:if>
                    <c:if test="${requestScope.userPageBean.currentPage!=requestScope.userPageBean.totalPage}">
                <li>
                    </c:if>
                    <a href="${pageContext.request.contextPath}/User/banTimeList?currentPage=${requestScope.userPageBean.currentPage+1}&rows=5"
                       aria-label="Next">
                        <span aria-hidden="true">&raquo;</span>
                    </a>
                </li>

                <span style="font-size: 25px;margin: 5px">
                共${requestScope.userPageBean.totalCount}条记录,共${requestScope.userPageBean.totalPage}页
                </span>
            </ul>
        </nav>
    </div>
</div>
</body>
</html>
